<template>
  <div style="margin: 40px">
    <el-form :inline="true" :model="queryOrder">
      <el-form-item label="订单号：">
        <el-input v-model="queryOrder.orderNo"></el-input>
      </el-form-item>
      <el-form-item label="课程名称：">
        <el-input v-model="queryOrder.courseTitle"></el-input>
      </el-form-item>
      <el-form-item label="讲师名称：">
        <el-input v-model="queryOrder.teacherName"></el-input>
      </el-form-item>
      <el-form-item label="会员手机：">
        <el-input v-model="queryOrder.mobile"></el-input>
      </el-form-item>
      <el-form-item label="订单状态：">
        <el-select v-model="queryOrder.status" placeholder="可选择订单状态" clearable>
          <el-option label="已支付" value="1"></el-option>
          <el-option label="未支付" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onQuery(1)">查询</el-button>
        <el-button @click="queryOrder={}">清空</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tableData" border fit>
      <el-table-column prop="orderNo" label="订单号" align="center"/>
      <el-table-column prop="courseTitle" label="课程名称" align="center"/>
      <el-table-column prop="teacherName" label="讲师名称" align="center"/>
      <el-table-column prop="nickname" label="会员昵称" align="center"/>
      <el-table-column prop="mobile" label="会员手机" align="center"/>
      <el-table-column prop="totalFee" label="订单金额" align="center"/>
      <el-table-column prop="payType" label="支付类型" align="center" v-slot="scope">
        {{scope.row.status===1?'微信':'支付宝'}}
      </el-table-column>
      <el-table-column prop="status" label="订单状态" align="center" v-slot="scope">
        {{scope.row.status===0?'未支付':'已支付'}}
      </el-table-column>
<!--      <el-table-column label="操作" align="center" width="200"  v-slot="scope">-->
<!--        <el-button type="primary" @click="toUpdate(scope.row.id)">编辑</el-button>-->
<!--        <el-button type="danger" @click="onDel(scope.row.id)">删除</el-button>-->
<!--      </el-table-column>-->
    </el-table>

    <el-pagination
      style="margin-top: 20px"
      background
      layout="prev, pager, next"
      :page-size="pageSize"
      :current-page="pageNum"
      @current-change="onQuery"
      :total="total"/>
  </div>
</template>

<script>
import {OrdPage} from "@/api/order";

export default {
  data() {
    return {
      queryOrder: {},
      pageNum: 1,
      pageSize: 2,
      total: 0,
      tableData: []
    }
  },
  created() {
    this.onQuery(1)
  },
  methods: {
    onQuery(pageNum) {
      this.pageNum = pageNum
      OrdPage(this.queryOrder, this.pageNum, this.pageSize).then(res => {
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
  }
}
</script>

<style>

</style>
